<template>
  <el-container>
  <el-aside :width="menuCollapse?'65px':'200px'">
     <el-menu
      background-color="#353B4E"
    text-color="#fff"
    active-text-color="#409EFC"
     class="el-menu-vertical-demo"
     :collapse-transition="false"
     :collapse="menuCollapse"
   >
 <el-menu-item index="1" :style="{width:menuCollapse?'65px':'200px'}">
        <i class="el-icon-menu"></i>
        <span slot="title">首页</span>
      </el-menu-item>
     <el-submenu index="2" :style="{width:menuCollapse?'65px':'200px'}">
         <template slot="title">
          <i class="el-icon-location"></i>
          <span>内容管理</span>
        </template>
        <el-menu-item index="2-1">发布文章</el-menu-item>
        <el-menu-item index="2-2">文章列表</el-menu-item>
        <el-menu-item index="2-3">评论管理</el-menu-item>
        <el-menu-item index="2-4">素材管理</el-menu-item>
     </el-submenu>
      <el-menu-item index="3" :style="{width:menuCollapse?'65px':'200px'}">
        <i class="el-icon-document"></i>
        <span slot="title">粉丝管理</span>
      </el-menu-item>
      <el-menu-item index="4" :style="{width:menuCollapse?'65px':'200px'}">
        <i class="el-icon-setting"></i>
        <span slot="title">账户管理</span>
      </el-menu-item>
    </el-menu>
  </el-aside>
  <el-container>
    <el-header>
      <div class="left">
        <i 
        :class="menuCollapse?'el-icon-s-fold':'el-icon-s-unfold'" 
        style="font-size:20px" @click="showMenu">
        </i>
        <span>江苏传智播客教育科技有限公司</span>
      </div>
      <div class="right">
        <el-input  placeholder="请输入搜索的文章" style="width:240px"></el-input>
        <span>消息</span>
          <el-dropdown trigger="click">
      <span class="el-dropdown-link">
        <img :src="photo" style="width:40px;height:40px"/>{{name}}
        <i class="el-icon-arrow-down el-icon--right"/>
      </span>
      <el-dropdown-menu slot="dropdown">
        <el-dropdown-item >个人信息</el-dropdown-item>
        <el-dropdown-item >git地址</el-dropdown-item>
        <el-dropdown-item @click.native="logout">退出</el-dropdown-item>
      </el-dropdown-menu>
    </el-dropdown>
      </div>
    </el-header>
    <el-main>
      <router-view></router-view>
    </el-main>

  </el-container>
</el-container>
</template>

<script>
export default {
  data () {
    return {
      menuCollapse: false // 菜单默认为展开
    }
  },
  methods: {
    logout () {
      this.$confirm('确认退出系统吗?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        // 清除缓存
        window.sessionStorage.clear()
        this.$router.push({
          name: '/login'
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        })
      })
    },
    showMenu () {
      this.menuCollapse = !this.menuCollapse
      console.log(this.menuCollapse)
    }
  },
  computed: {
    name () {
      return window.sessionStorage.getItem('name')
    },
    photo () {
      return window.sessionStorage.getItem('photo')
    }
  }
}
</script>

<style lang="less" scoped>
.el-container{
  height:100%;
  .el-aside{
    background: #323734;
  }
  .el-header{
    display: flex;
    align-items: center;
    justify-content: space-between;
    height:60px;
     .right{
       display: flex;
       align-items: center;
       width:500px;
     }
  }
}
</style>
